package com.ay.weixin.fdc.front.usercenter.event.old;
import java.io.IOException;

import javax.servlet.ServletException;

import org.lizar.config.keys.Keys;
import org.lizar.controller.Event;
import org.lizar.controller.intercepter.Before;
import org.lizar.controller.loader.BasicLoader;
import org.lizar.controller.loader.EventLoader;
import org.lizar.ioc.Container;

import com.ay.weixin.config.ProjectConfig;
import com.ay.weixin.config.types.UserType;
import com.ay.weixin.fdc.boss.user.db.FDCAgentDao;
import com.ay.weixin.fdc.front.usercenter.event.UserEvent;

public class UserLogin extends Event implements Before{
	private FDCAgentDao user_dao;
	private UserEvent user_event;
	private com.ay.weixin.fdc.front.usercenter.event.manager.UserLogin user_login;
	
	@Override
	public void init_property() throws Exception {
		user_dao=Container.get(FDCAgentDao.class);
		user_event=Container.get(UserEvent.class);
		user_login=Container.get(com.ay.weixin.fdc.front.usercenter.event.manager.UserLogin.class);
	}

	@Override
	public void before(BasicLoader bl) throws ServletException, IOException {
		long wxproject_id=bl.queryPathInt(3);
		bl.setAttr("vcode_used_error_in_times", ProjectConfig.get(wxproject_id,"fdc_usercenter.vcode_used_error_in_times"));
		bl.setAttr("user_type", UserType.old.name());
	}
	
	@Override
	public String default_handling_path() {
		return "/fdc/login/old/*";
	}

	@Override
	public void handle(EventLoader el) throws ServletException, IOException{
		long project_id=el.queryPathInt(3);
		System.out.println("project_id:"+project_id);
		
		user_login.handle(el,project_id);
	}
	

	

}
